Skip to content

Catch agnostic HTTP error types in yarn and swap the SSL test#24281

Open
mwdd146980 wants to merge 1 commit into
mwdd146980/httpx-migration-basefrom
mwdd146980/w1b-yarn
Open

Catch agnostic HTTP error types in yarn and swap the SSL test#24281
mwdd146980 wants to merge 1 commit into
mwdd146980/httpx-migration-basefrom
mwdd146980/w1b-yarn

Conversation

@mwdd146980

@mwdd146980 mwdd146980 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Widen the two HTTP exception handlers in yarn to catch the backend-agnostic http_exceptions types alongside the existing requests ones, and swap the SSL verification test to inject and assert the agnostic type.

Motivation

Part of the httpx migration. The agnostic http_exceptions hierarchy shares no base class with requests.exceptions, so the check must catch both families to keep working once the HTTP backend swaps to httpx. The lone Timeout handler pairs with HTTPTimeoutError; the four-type tuple (HTTPError, InvalidURL, ConnectionError, SSLError) pairs with HTTPStatusError, HTTPInvalidURLError, HTTPConnectionError, HTTPSSLError. No observable behavior change under the shipped requests backend.

Verification

Full yarn unit suite passes. Confirmed red-then-green on test_ssl_verification: with the test swapped to inject HTTPSSLError (including its own local except HTTPSSLError: around the checked call, not pytest.raises) and production left requests-only, the test fails with AssertionError: Needed exactly 1 candidates for 'yarn.can_connect', got 0, since the un-widened production handler never fires the CRITICAL service check. After widening, it passes. The Timeout widening has no test coverage either way and was verified by reading the handler, which mirrors the same log-and-reraise shape already proven by the SSL test. ddev test -fs is clean, and no requests reference remains in tests/test_yarn.py except the retained requests_get_mock fixture helper name.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mwdd146980 mwdd146980 added the qa/skip-qa Automatically skip this PR for the next QA label Jul 1, 2026
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Jul 1, 2026

Copy link
Copy Markdown

Pipelines  Tests  Code Coverage

Fix all issues with BitsAI

⚠️ Warnings

🚦 3 Pipeline jobs failed

PR | test / test-minimum-base-package (linux, ubuntu-22.04, yarn, Yarn (py3.13), py3.13) / minimum-base-package-Yarn (py3.13)-py3.13   View in Datadog   GitHub Actions

Validate repository | Run Validations / Validate   View in Datadog   GitHub Actions

PR | test / check   View in Datadog   GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 89.71% (+1.57%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: fa9b064 | Docs | Datadog PR Page | Give us feedback!

@mwdd146980 mwdd146980 marked this pull request as ready for review July 1, 2026 19:46
@mwdd146980 mwdd146980 requested a review from a team as a code owner July 1, 2026 19:46
@dd-octo-sts

dd-octo-sts Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Validation Report

Validation Description Status
dep Verify dependency pins are consistent and Agent-compatible

Run ddev validate all changed --fix to attempt to auto-fix supported validations.

Passed validations (20)
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa9b064670

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +496 to +499
HTTPStatusError,
HTTPInvalidURLError,
HTTPConnectionError,
HTTPSSLError,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Catch HTTPRequestError for httpx request failures

When the check runs with the httpx2 backend and httpx raises a protocol/generic request failure, the wrapper maps it to datadog_checks.base.utils.http_exceptions.HTTPRequestError (for example LocalProtocolError in the base httpx2 tests). This tuple only adds the narrower status/invalid-url/connection/SSL classes, while the HTTPError name here is still requests.exceptions.HTTPError, so those backend-agnostic request errors bypass the yarn.can_connect CRITICAL service check and escape without the expected failure reporting.

Useful? React with 👍 / 👎.

@@ -0,0 +1 @@
Catch the backend-agnostic HTTP error types when querying the YARN ResourceManager API so the check stays correct after the httpx migration.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a fixed changelog entry for this bug fix

This entry describes restoring correct behavior after the httpx migration, but .changed entries are reserved for breaking/significant changes and bump the integration's major version per the repo instructions. Shipping this as changed can publish an unnecessary major YARN release; please use a .fixed entry for this patch-level compatibility fix.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration/yarn qa/skip-qa Automatically skip this PR for the next QA team/agent-integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant